package Lesson16;

/*
 * set password in constructor
 * make method changePassword (String oldPass, String newPass)
 * use the password to return smth
 */

public class Person 
{
	static String courseName = "JAVAEE";
	public String name; // public value - can be reacht within the whole Java project
	String address; // package protected - within the package 
	private final String egn; // only in the class. the only way to set is is through constructor:
	private int age;
	private String password;
	
	
	Person (int age, String password, String egn)
	{
		this.egn = egn;
		this.age = age;
		this.password = password;
	}
	
	void changePassword (String oldPass, String newPass, String newPass2)
	{
		if (oldPass.equals(this.password) && newPass.equals(newPass2))
		{
			this.password = newPass;
		}
		else
			System.out.println("Wrong password!!");
	}
	
	void setAge (int age)
	{
		if (age >=0 && age <= 200)
		this.age = age;
	}
	
	int getAge(String password)
	{
		if(this.password.equals(password))
			return this.age;
		else
			return -1;
	}
}
